<template>
  <div>
    <!-- 旧件合格库存- 明细 -->
    <!-- 回运单信息 -->
    <BreakSpace label="回运单信息" :containerStyle="{ marginBottom: '10px' }" />
    <FormPanel ref="formPanel1" :list="formList1" :cols="3" :formType="'add'" labelWidth="100" :isSubmitBtn="false"
      @formChange="formChangeHandle" />
    <div style="padding-top: 3rem;"></div>
    <!-- 库存流水 -->
    <BreakSpace label="库存流水" :containerStyle="{ marginBottom: '10px' }" />
    <FilterTable ref="table1" :columns="columns" :params="fetchParams" :dataSource="dataList" :datakey="'items'"
      :onColumnsChange="columns => (this.columns = columns)" :onRowSelectChange="selectChange" selectionType="single"
      height="auto" :isPagination=false :isSelectColumn=false>
    </FilterTable>
    <div style="padding-top: 3rem;"></div>
    <div :style="{
      position: 'absolute',
      left: 0,
      bottom: 0,
      right: 0,
      zIndex: 9,
      borderTop: '1px solid #e9e9e9',
      padding: '10px 20px',
      background: '#fff',
      textAlign: 'right'
    }">
      <multiuse-button @click="closeDialog">返回</multiuse-button>
    </div>
  </div>
</template>
<script>
import { selectById,findFileByUrl } from '@/api/usedPartsReturnManage/usedPartsReturn_OEM/usedPartsPass';
import { dictionary } from '@/utils/dictMixin';
export default {
  props:['rowData'],
  mixins: [dictionary],
  components: {

  },
  data() {
    return {
      dataList: [],
      visible: false,
      visibleDrawer: false,
      collapse: false,
      infoId: null,
      flterValue: {}, //参数
      columns: this.creatHeader(),
      fetchParams: {}, //ipa 接口
      selectedRows: [], //选中服务站
      formList1: this.createFormList(),
      saveData: null
    };
  },
  async created() {
    this.formList1.forEach(x => {
      x.initialValue = this.rowData[x.fieldName];
      x.disabled = true;
    });
    let res = await selectById({id:this.rowData.partCode});
    this.dataList = res.data;
  },

methods: {
    // 获取服务端文件 to blob
    async downLoadByUrl(url, params = {}) {
      let res = await findFileByUrl(url);
      console.log(res.data)
      return res.data;
    },
    formChangeHandle(val) {
      console.log(val);
      this.saveData = val;
    },
    //选中
     selectChange(rows) {
      this.selectedRows = rows;
      this.TurnOn =
        console.log(this.selectedRows);
    },
    //保存
    saveDialog() {
      this.$refs.formPanel1.SUBMIT_FORM();
      if (this.saveData) {
        this.$emit('save', this.selectedRows);
      }
    },
    //取消操作
    closeDialog() {
      this.$emit('close', { visible: false, data: this.selectedRows, type: 'close' });
    },
    chooseOrderNo() {
      this.visible = true;
    },
    //回运单信息
    createFormList() {
      return [
        {
          type: 'INPUT',
          label: '旧件代码',
          fieldName: 'partCode',
          disabled: true, // 置会
          readonly: true // 只读
        },
        {
          type: 'INPUT',
          label: '旧件名称',
          fieldName: 'partName',
          disabled: true, // 置会
          readonly: true // 只读
        },
        {
          type: 'INPUT',
          label: '旧件库存数量',
          fieldName: 'stockCount',
          disabled: true, // 置会
          readonly: true // 只读
        },

        {
          type: 'INPUT',
          label: '责任商代码',
          fieldName: 'supplierCode',
          readonly: true,// 只读
          disabled: true, // 置会
          hidden: false
        },
        {
          type: 'INPUT',
          label: '责任商名称',
          fieldName: 'supplierName',
          disabled: true, // 置会
          readonly: true // 只读
        }
      ];
    },

    //库存流水
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        { title: '操作人', dataIndex: 'createdByStr', sorter: true },
        { title: '库存调整', dataIndex: 'resetCount', sorter: true },
        { title: '服务中心代码', dataIndex: 'dealerCode', sorter: true },
        { title: '服务中心简称', dataIndex: 'dealerName', sorter: true, width: 200 },
        { title: '回运单号', dataIndex: 'returnNo', sorter: true, width: 150 },
        { title: '回运类型', dataIndex: 'returnType', sorter: true,dictItems: this.createDictList('5595'), },
        { title: '索赔单号', dataIndex: 'claimNo', sorter: true },
        {title: '操作时间', dataIndex: 'createdAt', sorter: true,width:150 },
        {title: '操作说明', dataIndex: 'remark', sorter: true,width:300 },
        /* 旧件列表得数据 */
        /* { title: '服务中心代码', dataIndex: 'ownerCode', sorter: true },
        { title: '服务中心简称', dataIndex: 'dealerName', sorter: true },
        { title: '索赔单号', dataIndex: 'cmsClaimNo', sorter: true },
        { title: 'VIN', dataIndex: 'vin', sorter: true, width: 150 },
        { title: '车型名称', dataIndex: 'modelName', sorter: true },
        { title: '索赔类型', dataIndex: 'cmsClaimType', sorter: true ,dictItems: this.createDictList('5510'),},
        { title: '旧件代码', dataIndex: 'partCode', sorter: true },
        { title: '旧件名称', dataIndex: 'partName', sorter: true },
        { title: '旧件供应商代码', dataIndex: 'supCode', sorter: true },
        { title: '旧件供应商名称', dataIndex: 'supName', sorter: true },
        { title: '旧件数量', precision: 0, dataIndex: 'inCount', sorter: true },
        {
          title: '合格数量',
          dataIndex: 'qualifiedCount',
          sorter: true,
          minWidth: 120,
          editable: true,
          defaultEditable: true,
          showOverflowTooltip: true,
          editType: 'input',
          disabled: true // 置会
        }, */
    ];
    },
  }
};
</script>
<style lang="less" scoped>

</style>
